#include <iostream>
using namespace std;

class MyComplex
{
public:
    MyComplex(int x = 0, int y = 0)
    {
        a = x;
        b = y;
    }

    void print()
    {
        if (this->b == 0)
        {
            cout << a << endl;
        }
        else
        {
            cout << a << " + " << b << "i" << endl;
        }
    }

    MyComplex operator+(MyComplex &other)
    {
        MyComplex temp;
        temp.a = this->a + other.a;
        temp.b = this->b + other.b;
        return temp;
    }
    MyComplex operator-(MyComplex &other)
    {
        MyComplex temp;

        temp.a = this->a - other.a;
        temp.b = this->b - other.b;
        return temp;
    }
    MyComplex operator*(MyComplex &other)
    {
        MyComplex temp;
        temp.a = this->a * other.a - this->b * other.b;
        temp.b = this->a * other.b + this->b * other.a;
        return temp;
    }
    MyComplex operator/(MyComplex &other)
    {
        MyComplex temp;
        int z = other.a * other.a + other.b * other.b;
        int x = (this->a * other.a + this->b * other.b) / z;
        int y = (this->b * other.a - this->a * other.b) / z;
        temp.a = x;
        temp.b = y;
        return temp;
    }

private:
    int a, b;
};

int main()
{

    MyComplex a(1, 2), b(3, 4), c(5, 10);
    (a + b).print();
    (a - b).print();
    (a * b).print();
    (c / a).print();
    return 0;
}